<?php
$limit = 10; // For pagination purposes

//Get the entities and show them
$entities = elgg_get_entities(array
(
	'type' => 'object',
	'subtype' => 'organization',
	"offset" => get_input('offset') ? get_input('offset') : 0,
	"limit" => $limit,
));

if(count($entities))
{
	//Pagination
	$count = elgg_get_entities(array
	(
		'type' => 'object',
		'subtype' => 'organization',
		"count" => TRUE,
	));

	$pagination = elgg_view('navigation/pagination', array
	(
		'baseurl' => $CONFIG->url."admin/organizations/list",
		'offset' => get_input('offset') ? get_input('offset') : 0,
		'count' => $count,
		'limit' => $limit,
		'offset_key' => 'offset',
	));
}
else
{
	echo elgg_echo('admin:organizations:list:no_results');
}

$baseHref = $CONFIG->url."admin/organizations/edit?o=";
?>

<style>
td
{
	vertical-align:middle;
}
</style>
<?php echo $pagination; ?>
<table class="elgg-table">
<thead>
	<tr>
		<th>&nbsp;</th>
		<th>Nombre</th>
		<th>Direccion</th>
		<th>Telefono</th>
		<th>Web</th>
		<th>CIF</th>
		<th>&nbsp;</th>
	</tr>
</thead>
<tbody>
	<?php foreach ($entities as $entity): ?>
		<tr>
			<td width="25"><?php echo elgg_view_entity_icon($entity, 'small', array('href' => '')); ?></td>
			<td>
			<?php
				echo elgg_view("output/url",
				array('href' => $entity->getUrl() ,'text' => $entity->title));
			?>
			</td>
			<td><?php echo $entity->address; ?></td>
			<td><?php echo $entity->phone; ?></td>
			<td><?php echo $entity->web; ?></td>
			<td><?php echo $entity->cif; ?></td>
			<td>
			<?php
				echo elgg_view("output/url",
				array('href' => $baseHref.$entity->guid ,'text' => elgg_echo('edit'),'class' => 'elgg-button elgg-button-cancel',));
			?>
			</td>
		</tr>
	<?php endforeach; ?>
</tbody>
</table>

<?php echo $pagination; ?>